package guoanmaker.operator.business.controller;

import guoanmaker.operator.business.model.OperatorCouponPage;
import guoanmaker.operator.business.service.OperatorCouponPageServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 *  
 *
 * @author huZhaoyu 
 * @ClassName: OperatorCouponPageController
 * @Description: OperatorCouponPageController 
 * @date 2017/6/28 下午3:01 
 */
@RestController
@RequestMapping(ApiController.OPERATOR_COUPONPAGE_URL)
public class OperatorCouponPageController {
    private final OperatorCouponPageServiceInterface operatorCouponPageServiceInterface;

    public OperatorCouponPageController(OperatorCouponPageServiceInterface operatorCouponPageServiceInterface) {
        this.operatorCouponPageServiceInterface = operatorCouponPageServiceInterface;
    }

    /** 
    * @Title: saveCouponPage
    * @Description: 新增/修改优惠劵页 
    * @param: OperatorCouponPage   
    * @return AjaxJson    
    * @throws 
    */
    @ApiOperation(value = "保存优惠劵页", notes = "新增/修改优惠劵页")
    @PostMapping(value = "saveCouponPage")
    public AjaxJson saveCouponPage(@RequestBody OperatorCouponPage operatorCouponPage) {
    	AjaxJson ajaxJson=new AjaxJson();
    	return ajaxJson.setSuccess(true).setStatus(200).setData(operatorCouponPageServiceInterface.saveCouponPage(operatorCouponPage));
    }

    /** 
     * @Title: deleteCouponPageById
     * @Description: 根据Id删除优惠劵页
     * @param: String id  
     * @return AjaxJson 
     * @throws 
     */
    @ApiOperation(value = "删除优惠劵页", notes = "根据Id删除优惠劵页")
    @DeleteMapping(value = "delete/{id}")
    public AjaxJson deleteCouponPageById(@PathVariable(value = "id") String id) {
    	AjaxJson ajaxJson=new AjaxJson();
    	operatorCouponPageServiceInterface.deleteCouponPageById(id);
        return ajaxJson.setSuccess(true).setStatus(200).setData("数据删除成功!");
    }

    /**
     * @return OperatorCouponPage    
     * @Title: getCouponPageById 
     * @Description: 根据Id查询优惠劵页
     * @param: String id   
     * @throws 
     */
    @ApiOperation(value = "根据Id查询优惠劵页", notes = "根据Id查询优惠劵页")
    @GetMapping(value = "getCouponPageById")
    public AjaxJson getCouponPageById(@RequestParam(value = "id") String id) {
    	AjaxJson ajaxJson=new AjaxJson();
    	return ajaxJson.setSuccess(true).setStatus(200).setData(operatorCouponPageServiceInterface.getCouponPageById(id));
    }

    /**
     * @return AjaxJson   
     * @Title: getAllCouponPage
     * @Description: 查找所有优惠劵页 
     * @throws 
     */
    @ApiOperation(value = "查找所有优惠劵页", notes = "查找所有优惠劵页")
    @GetMapping(value = "getAllCouponPage")
    public AjaxJson getAllCouponPage() {
    	AjaxJson ajaxJson=new AjaxJson();
        return ajaxJson.setSuccess(true).setStatus(200).setData(operatorCouponPageServiceInterface.getAllCouponPage());
    }

    /**
     * @return AjaxJson   
     * @Title: getAllCouponPageByPage 
     * @Description: 查询所有优惠劵页并分页
     * @param: Integer page 页码
     * @param: Integer size 条数
     * @throws 
     */
    @ApiOperation(value = "分页查询优惠劵页", notes = "分页查询优惠劵页")
    @GetMapping(value = "getAllCouponPageByPage")
    public AjaxJson getAllCouponPageByPage(@RequestParam(value = "page", defaultValue = "0") Integer page,
                                           @RequestParam(value = "size", defaultValue = "10") Integer size) {
    	AjaxJson ajaxJson=new AjaxJson();
    	return ajaxJson.setSuccess(true).setStatus(200).setData(operatorCouponPageServiceInterface.getAllCouponPageByPage(page, size));
    }

}
